# Maintainer: Christoph Reiter <reiter.christoph@gmail.com>

_realname=gst-devtools
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.18.0
pkgrel=1
pkgdesc="Development and debugging tools for GStreamer (mingw-w64)"
arch=('any')
url="https://gstreamer.freedesktop.org/"
license=("LGPL")
makedepends=("${MINGW_PACKAGE_PREFIX}-meson"
             "${MINGW_PACKAGE_PREFIX}-ninja"
             "${MINGW_PACKAGE_PREFIX}-gobject-introspection")
depends=("${MINGW_PACKAGE_PREFIX}-gstreamer"
         "${MINGW_PACKAGE_PREFIX}-gst-plugins-base"
         "${MINGW_PACKAGE_PREFIX}-json-glib")
options=(!libtool strip)
source=(https://gstreamer.freedesktop.org/src/${_realname}/${_realname}-${pkgver}.tar.xz)
sha256sums=('82337141b5654f11c440f783892ba9d9498b3b6b98c2286b000f96dce6945f16')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

}

build() {
  [[ -d "${srcdir}/build-${MINGW_CHOST}" ]] && rm -rf "${srcdir}/build-${MINGW_CHOST}"
  mkdir -p "${srcdir}/build-${MINGW_CHOST}"
  cd "${srcdir}/build-${MINGW_CHOST}"

  ${MINGW_PREFIX}/bin/meson \
    --buildtype plain \
    --wrap-mode=nofallback \
    -Dauto_features=enabled \
    -Dtests=disabled \
    -Ddoc=disabled \
    ../${_realname}-${pkgver}

  ninja
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"

  DESTDIR="${pkgdir}${MINGW_PREFIX}" ninja install

  for pcfile in  "${pkgdir}${MINGW_PREFIX}"/lib/pkgconfig/*.pc; do
    sed -s "s|$(cygpath -m ${MINGW_PREFIX})|${MINGW_PREFIX}|g" -i "${pcfile}"
  done
}
